<?php
$keyword = $_GET['keyword'];
$keyword = preg_replace('/(5·12)|(512)/','5.12',$keyword);

if ($_SESSION[$keyword])
{
	$id_arr = explode(',',$_SESSION[$keyword]);
	$total = count($id_arr);
}
else
{
	include_once('model/search.php');
	$search = new LZ_Search;
	$id_arr = $search->search('photo',$keyword);
	$total = count($id_arr);
	if ($total > 0)
	{
		$_SESSION['search_keyword'] = $keyword;
		$_SESSION[$keyword] = join(',',$id_arr);
	}
}
cache_this_page();


if ($total <= 0)
{
	lz_exit(NO_RESULT,'index.php',5);
}


include_once('model/photo.php');
$obj = new LZ_Photo;

$page = intval($_GET['page']);
$per_page = (intval($config['image_per_page']))?intval($config['image_per_page']):30;
!$page && $page=1;
$total_page = ceil($total/$per_page);
!$total_page && $total_page=1;
$page>$total_page && $page = $total_page;
$image_list = array();
$from = ($page-1)*$per_page;
for($i=$from;$i<$from+$per_page && $i<$total;$i++)
{
	$image_list[] = $obj->get_one($id_arr[$i]);
}

$pager = PAGER_TOTAL.$total.PAGER_ITEMS.' ';
$total_page > 1 && $pager.= $total_page.PAGER_PAGE;
$pager.='<br />';
$pager.= html_pager("search.php?keyword=".$keyword,$total_page,$page);

$_SESSION['last_list_page'] = "search.php?keyword=$keyword&page=$page";
$view_data['page'] = $page;
$view_data['time'] = $time;
$view_data['pager'] = $pager;
$view_data['title'] = '"'.$keyword.'" '.SEARCH_RESULT;
$view_data['image_list'] = $image_list;
$view_data['page_description'] = '"'.$keyword.'" '.SEARCH_RESULT;
$view_data['site_keywords'] = $keyword;

include_once('left.php');
?>